- id = "c"+rand.to_s[2..-1].to_i.to_s(36)
- condition =  params[:condition]||'unknown'
- params[:conditions] ||=  {}
- params[:conditions][id] ||=  {}
.condition{id: id}
  .title
    .right-menu=  link_to("rest.actions.destroy".tl, "#", "data- remove" => "##{id}", class: "icon im-delete")
    .right-menu
      =  check_box_tag("conditions[#{id}][reverse]", "1", params[:conditions][id][:reverse], id: "conditions_#{id}_reverse")
      %label{:for => "conditions_#{id}_reverse"}=  :reverse.tl
    %h3.icon.im-filter= condition_label(condition)
  .preferences
    = hidden_field_tag("conditions[#{id}][type]", condition)
    .param
      = check_box_tag("conditions[#{id}][use_timestamp]")
      =  :created_between.tl(:started_at => date_field_tag("conditions[#{id}][timestamp][started_at]", Time.zone.today - 6), :stopped_at => date_field_tag("conditions[#{id}][timestamp][stopped_at]", Time.zone.today)).html_safe
    - if condition ==  "special-subscriber"
      .param
        - for nature in SubscriptionNature
          = radio_button_tag("conditions[#{id}][nature]", nature.id, params[:conditions][id][:nature] ==  nature.id.to_s, id: "conditions_#{id}_nature_#{nature.id}", "data-show" => "#conditions_#{id}_nature_#{nature.id}_detail")
          %label{:for => "conditions_#{id}_nature_#{nature.id}"}= h(nature.name)
      - for nature in SubscriptionNature
        %div{id: "conditions_#{id}_nature_#{nature.id}_detail", :style => 'display:none'}
          .param
            = check_box_tag("conditions[#{id}][#{nature.id}][use_subscribed_at]", "1", true)
            =  "subscriber_#{nature.nature}".tl(:subscribed_at => (nature.period? ? date_field_tag("conditions[#{id}][#{nature.id}][subscribed_at]", Time.zone.today) : text_field_tag("conditions[#{id}][#{nature.id}][subscribed_at]", nature.actual_number, :size => 8))).html_safe
          .param
            - for product in nature.products
              = check_box_tag("conditions[#{id}][#{nature.id}][products][#{product.id}]", "1", true, id: "conditions_#{id}_#{nature.id}_products_#{product.id}")
              %label{:for => "conditions_#{id}_#{nature.id}_products_#{product.id}"}= product.name
            = check_box_tag("conditions[#{id}][#{nature.id}][no_products]", "1", true, id: "conditions_#{id}_#{nature.id}_no_products")
            %label{:for => "conditions_#{id}_#{nature.id}_no_products"}=  :no_products.tl
    - elsif condition ==  "special-buyer"
    - elsif condition ==  "special-relation"
    - elsif condition.match(/^generic/)
      - klass, attribute =  condition.split(/\-/)[1].classify.constantize, condition.split(/\-/)[2]
      - column =  klass.columns_hash[attribute]
      .param
        -# TODO Adds translation support !!!!!!!!!!!!!!!!!!!!
        %label= klass.human_attribute_name(attribute)
        - if column.type ==  :decimal
          = select_tag("conditions[#{id}][comparator]", options_for_select([["est supérieur(e) à", :gt], ["est supérieur(e) ou égal(e) à", :ge], ["est égal(e) à", :eq], ["est inférieur(e) ou égal(e) à", :le], ["est inférieur(e)", :lt]]))
          = text_field_tag("conditions[#{id}][comparated]")
        - elsif column.type ==  :date
          = select_tag("conditions[#{id}][comparator]", options_for_select([["est supérieur(e) à", :gt], ["est supérieur(e) ou égal(e) à", :ge], ["est égal(e) à", :eq], ["est inférieur(e) ou égal(e) à", :le], ["est inférieur(e)", :lt]]))
          = date_field_tag("conditions[#{id}][comparated]", Time.zone.today)
        - elsif column.type ==  :boolean
          = select_tag("conditions[#{id}][comparator]", options_for_select([["est vrai", :is_true], ["est faux", :is_false]]))
        - else
          = select_tag("conditions[#{id}][comparator]", options_for_select([["contient", :contains], ["commence par", :begins], ["finit par", :finishes], ["est", :equal], ["est égal à l'un des élements suivants", :in]]))
          = text_field_tag("conditions[#{id}][comparated]")
    - else
      =  :unknown_condition.tl
